package commonClass;

import java.text.SimpleDateFormat;
import java.util.Date;

public class ID {

	private static int NUM=0;
	private static int MIN_NUM=0;
	private static int MAX_NUM=999999;
	private static String ZERO="000000";
	private static String FORMAT="yyyyMMddHHmmss";

	/**
	 * 平台号(3位)+yyyyMMddHHmmss+六位数的连续数字
	 * @return
	 */
	public synchronized static String getUUID(){
		NUM++;
		if(NUM>MAX_NUM)
			NUM=MIN_NUM;
		return new SimpleDateFormat(FORMAT).format(new Date())+
					ZERO.substring(String.valueOf(NUM).length())+NUM;
	}
	
	public static void main(String[] args) {
	    for(int k=0;k<1000;k++){
	    	new Thread(new Runnable(){
				@Override
				public void run() {
					System.out.println(ID.getUUID());
				}
			}).start();
	    }
	}
}
